# http://in.finitu.de/2008/11/01/reading-pdf-properties-with-ruby
# http://github.com/yob/pdf-reader/tree/master
# http://groups.google.com/group/pdf-reader

#!/usr/bin/ruby

require 'rubygems'
require 'pdf/reader'

	class MetaDataReceiver
    		attr_accessor :regular
    		attr_accessor :xml

    	def metadata(data)
      		@regular = data
    	end

    	def metadata_xml(data)
     		 @xml = data
    	end
  	end

	begin
		#file = ARGV
		#files = Dir.glob("#{directory}/*")
		#	files.each do |f| puts f
  		receiver = MetaDataReceiver.new
  		pdf = PDF::Reader.file(ARGV.shift, receiver, :pages => false, :metadata => true)
		#puts receiver.regular.inspect
  		metadata = receiver.regular.inspect
  		puts receiver.xml.inspect
  		puts metadata.split(":")	
		puts ("----------")
		
	
	#rescue MalformedPDFError => e
	#	puts #{e}
	#rescue UnsupportedFeatureError => e
	#	puts #{e}
	rescue => e
		puts #{e}
	end

#would not parse PScript5.dll Version 5.2.2 created pdfs...not sure why

